import { Request, Controller, Post, UseGuards, Body } from '@nestjs/common';
import { LocalAuthGuard } from '../../guard/local-auth.guard';
import { AuthService } from './auth.service';
import { UserDto } from '../users/user.dto';
import { User } from '../../database/schemas/user.schema';

@Controller('auth')
export class AuthController {
  constructor(private readonly authService: AuthService) {}

  @UseGuards(LocalAuthGuard)
  @Post()
  async signIn(@Request() request) {
    return this.authService.signIn(request.user);
  }

  @Post('sign-up')
  async signUp(@Body() newUser: UserDto): Promise<User> {
    return this.authService.signUp(newUser);
  }
}
